package demogo

import "log"

func Slice() {
	{
		a := make([]int, 20)
		for i := 0; i < len(a); i++ {
			a[i] = i
		}
		log.Println("a=", a)
		b := a[17:19]
		log.Println("b=", b)
		b = append(b, -1)
		log.Println("在a[17:19]后面插入一个元素，a是否会受影响")
		log.Println("a=", a)
		log.Println("b=", b)
	}
	log.Println("=================")
	{
		a := make([]int, 20)
		for i := 0; i < len(a); i++ {
			a[i] = i
		}
		log.Println("a=", a)
		b := a[17:19]
		log.Println("b=", b)
		b = append(b, -1, -2, -3, -4, -5, -6)
		log.Println("在a[17:19]后面插入多个元素，a是否会受影响")
		log.Println("a=", a)
		log.Println("b=", b)
	}
	log.Println("=================")
	{
		a := make([]int, 20)
		for i := 0; i < len(a); i++ {
			a[i] = i
		}
		log.Println("a=", a)
		b := a[17:19]
		log.Println("b=", b)
		b = append(b, -1)
		log.Println("在a[17:19]后面插入一个元素，a是否会受影响")
		log.Println("a=", a)
		log.Println("b=", b)
		b = append(b, -2, -3, -4, -5, -6)
		log.Println("在a[17:19]后面插入多个元素，a是否会受影响")
		log.Println("a=", a)
		log.Println("b=", b)
	}
}
